package com.focus.ctrl.demo.web.maphandler;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.focus.ctrl.demo.model.User;

@Controller
@SessionAttributes("user")
@RequestMapping("/session")
public class SessionController {

	@RequestMapping("")
	public String add(HttpSession session) {
		User user = new User();
		user.setName("tom");
		user.setPassword("123456");
		session.setAttribute("user", user);

		return "session/new";
	}

	@RequestMapping("/list")
	public String list(@ModelAttribute User user) {
		return "session/list";
	}

	@RequestMapping("/rnsession")
	public void rm(HttpSession session) {
		session.invalidate();
	}
}
